<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>P2 Project - GanttMaker: SW2A311_Lib/Serialization.cs Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="client.ico"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">P2 Project - GanttMaker
   &#160;<span id="projectnumber">1.1.0.0</span>
   </div>
   <div id="projectbrief">By student group SW2A311, Aalborg University</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_serialization_8cs_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Properties</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Events</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Serialization.cs</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_serialization_8cs.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;﻿using System;</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="keyword">using</span> System.IO;</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="keyword">using</span> System.Runtime.Serialization;</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="keyword">using</span> System.Runtime.Serialization.Formatters.Binary;</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;</div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="keyword">namespace </span>SW2A311_Lib</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;{</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">    #region Enums</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"><a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">    9</a></span>&#160;<span class="preprocessor"></span>    <span class="keyword">public</span> <span class="keyword">enum</span> <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a> { <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5a9e727fdd3aec8274f46685441900280d">Project</a>, <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5acd02c98dade804f707016f2cfbe2519c">CreateUser</a>, <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5a55dcdf017b51fc96f7b5f9d63013b95d">Chat</a>, <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5a0a9a6bdad5d3f65845a9373c7760b71d">LogInUser</a> };</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">    #endregion</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">    #region Klasser</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div>
<div class="line"><a name="l00022"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html">   22</a></span>&#160;    <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html" title="Klasse med metoderne til at skrive objekter til en fil. ">ObjectToFile</a></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    {</div>
<div class="line"><a name="l00027"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a778b06ded4e9f173c2627473214a9ef0">   27</a></span>&#160;        <span class="keyword">private</span> BinaryFormatter <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a778b06ded4e9f173c2627473214a9ef0" title="BinaryFormatter instantieres. ">bFormatter</a> = <span class="keyword">new</span> BinaryFormatter();</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a28924db0a396fe73f2b0c4dd5b47b511">   29</a></span>&#160;        <span class="keyword">public</span> <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a28924db0a396fe73f2b0c4dd5b47b511">ObjectToFile</a>()</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        {</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        }</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a5736da0c541490555632c9f50b901974">   42</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a5736da0c541490555632c9f50b901974" title="Metoden tager et filnavn og objektet der skal gemmes og skriver det i en fil med det givne navn...">SerializeObject&lt;T&gt;</a>(<span class="keywordtype">string</span> filename, T objectToSerialize)</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        {</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;            Stream stream = File.Open(filename, FileMode.Create); <span class="comment">// Der instantieres/forberedes et stream til en fil med valgte navn.</span></div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a778b06ded4e9f173c2627473214a9ef0" title="BinaryFormatter instantieres. ">bFormatter</a>.Serialize(stream, objectToSerialize);      <span class="comment">// BinaryFormatter serialisere ObjectToSerialize og sender resultatet til vores stream der skriver det til filen.</span></div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;            stream.Close();</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        }</div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a267bde809fc2ebd27e4028888be60498">   57</a></span>&#160;        <span class="keyword">public</span> T <a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a267bde809fc2ebd27e4028888be60498" title="Læser fra filen med det givne filnavn og returnerer et objekt med af den givne type. ">DeSerializeObject&lt;T&gt;</a>(<span class="keywordtype">string</span> filename)</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        {</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;                T objectToDeserialize;                                <span class="comment">// Der genereres et tomt object svarende til det vi vil hente fra filen.</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;                Stream stream = File.Open(filename, FileMode.Open);   <span class="comment">// Et stream åbnes fra filen.</span></div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                objectToDeserialize = (T)<a class="code" href="class_s_w2_a311___lib_1_1_object_to_file.html#a778b06ded4e9f173c2627473214a9ef0" title="BinaryFormatter instantieres. ">bFormatter</a>.Deserialize(stream); <span class="comment">// Vores stream deserialiseres og dataen indsættes i det tomme objekt.</span></div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;                stream.Close();</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;                <span class="keywordflow">return</span> objectToDeserialize;                           <span class="comment">// Objektet returneres.</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        }</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    }</div>
<div class="line"><a name="l00075"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html">   75</a></span>&#160;    <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html" title="Klasse med metoderne til at skrive objekter til et byte array. ">ObjectToByteArray</a></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    {</div>
<div class="line"><a name="l00080"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#a8cebf21ce1fc9a70df740a4716dfbd21">   80</a></span>&#160;        <span class="keyword">private</span> BinaryFormatter <a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#a8cebf21ce1fc9a70df740a4716dfbd21" title="BinaryFormatter instantieres. ">bFormatter</a> = <span class="keyword">new</span> BinaryFormatter();</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;</div>
<div class="line"><a name="l00082"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#a318d09b31e3f4972388482260ae97574">   82</a></span>&#160;        <span class="keyword">public</span> <a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#a318d09b31e3f4972388482260ae97574">ObjectToByteArray</a>()</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        {</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        }</div>
<div class="line"><a name="l00094"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#ae86fa1b20b36849c7730d2a0f10a723f">   94</a></span>&#160;        <span class="keyword">public</span> byte[] <a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#ae86fa1b20b36849c7730d2a0f10a723f" title="Metoden tager et objekt og serializerer det, hvorefter det returneres i et byte-array. ">SerializeObject&lt;T&gt;</a>(T objectToSerialize)</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        {</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;            byte[] byteArray;                                    <span class="comment">// Tomt byte array instantieres så det kan modtage den serialiserede data.</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;            MemoryStream stream = <span class="keyword">new</span> MemoryStream();            <span class="comment">// Der instantieres et stream i hukommelsen.</span></div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#a8cebf21ce1fc9a70df740a4716dfbd21" title="BinaryFormatter instantieres. ">bFormatter</a>.Serialize(stream, objectToSerialize);     <span class="comment">// objectToSerialize serialiseres med BinaryFormatter og sendes til vores stream.</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;            byteArray = stream.ToArray();                        <span class="comment">// Streamet med dataen skrives i det tomme byte array.</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;            stream.Close();</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;            <span class="keywordflow">return</span> byteArray;                                    <span class="comment">// Arrayet med dataen returneres.</span></div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        }</div>
<div class="line"><a name="l00112"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#abdf1206bdce03c6720518d703516e926">  112</a></span>&#160;        <span class="keyword">public</span> T <a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#abdf1206bdce03c6720518d703516e926" title="Metoden skal have en returtype og et byte array og deserialiserer derefter byte array&#39;et og returnere...">DeSerializeObject&lt;T&gt;</a>(byte[] byteArray)</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;        {</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;            T objectToSerialize;                                  <span class="comment">// Objekt instantieres.</span></div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;            MemoryStream stream = <span class="keyword">new</span> MemoryStream(byteArray);    <span class="comment">// Stream instatieres i hukommelsen.</span></div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;            objectToSerialize = (T)<a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html#a8cebf21ce1fc9a70df740a4716dfbd21" title="BinaryFormatter instantieres. ">bFormatter</a>.Deserialize(stream);<span class="comment">// Streamet deserialiseres og dataen lægges i det tomme objekt. </span></div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;            stream.Close();</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;            <span class="keywordflow">return</span> objectToSerialize;                             <span class="comment">// Objektet returneres.   </span></div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        }</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    }</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    [Serializable()]</div>
<div class="line"><a name="l00127"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html">  127</a></span>&#160;    <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html" title="EncapsulationClass bruges til at indkapsle de objekter vi sender over netværket så vi nemt kan deseri...">EncapsulationClass</a> : ISerializable</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    {</div>
<div class="line"><a name="l00129"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a1c7dda9c812daf824382f802e6c14c4b">  129</a></span>&#160;        <span class="keyword">public</span> byte[] <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a1c7dda9c812daf824382f802e6c14c4b">SentObject</a> { <span class="keyword">get</span>; <span class="keyword">private</span> <span class="keyword">set</span>; }          <span class="comment">// Objektet der skal sendes.</span></div>
<div class="line"><a name="l00130"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">  130</a></span>&#160;        <span class="keyword">public</span> <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a> <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a> { <span class="keyword">get</span>; <span class="keyword">private</span> <span class="keyword">set</span>; }        <span class="comment">// Objektets type gemmes i en type vi har defineret som ObjectType.</span></div>
<div class="line"><a name="l00138"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a400de9c64dd2ae5e8b5fafe4f3202b12">  138</a></span>&#160;<span class="comment"></span>        <span class="keyword">public</span> <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a400de9c64dd2ae5e8b5fafe4f3202b12" title="Constructoren tager det object der skal indkapsles som input og gemmer det i SentObject field...">EncapsulationClass</a>(<span class="keywordtype">object</span> objectIn)</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;        {</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html" title="Klasse med metoderne til at skrive objekter til et byte array. ">ObjectToByteArray</a> serializer = <span class="keyword">new</span> <a class="code" href="class_s_w2_a311___lib_1_1_object_to_byte_array.html" title="Klasse med metoderne til at skrive objekter til et byte array. ">ObjectToByteArray</a>();     <span class="comment">// ObjectToByteArray instantieres. </span></div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#add828aba2ab1d1a9016cc459ae3f1bc3" title="Finder en TypeCode ud fra objektets .GetType og gemmer det i TypeCode field. ">GetObjectType</a>(objectIn);                                    <span class="comment">// Vi finder og gemmer objektets type med GetObjectType metoden.</span></div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;            <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a1c7dda9c812daf824382f802e6c14c4b">SentObject</a> = serializer.SerializeObject&lt;<span class="keywordtype">object</span>&gt;(objectIn);  <span class="comment">// Objektet serialiseres og gemmes.</span></div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;        }</div>
<div class="line"><a name="l00149"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#ad1de16e4f6362f1387906ea269777033">  149</a></span>&#160;        <span class="keyword">public</span> <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a400de9c64dd2ae5e8b5fafe4f3202b12" title="Constructoren tager det object der skal indkapsles som input og gemmer det i SentObject field...">EncapsulationClass</a>(SerializationInfo info, StreamingContext ctxt)</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        {</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;            this.<a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a1c7dda9c812daf824382f802e6c14c4b">SentObject</a> = (byte[])info.GetValue(<span class="stringliteral">&quot;SentObject&quot;</span>, typeof(byte[]));</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;            this.<a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a> = (<a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a>)info.GetValue(<span class="stringliteral">&quot;TypeCode&quot;</span>, typeof(<a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a>));</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;        }</div>
<div class="line"><a name="l00159"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a91d7e43c8625bfb1a30cc86fbf77ce1d">  159</a></span>&#160;        <span class="keyword">public</span> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a91d7e43c8625bfb1a30cc86fbf77ce1d" title="Metode til deserializering. ">GetObjectData</a>(SerializationInfo info, StreamingContext ctxt)</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;        {</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;            info.AddValue(<span class="stringliteral">&quot;SentObject&quot;</span>, this.<a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a1c7dda9c812daf824382f802e6c14c4b">SentObject</a>);</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;            info.AddValue(<span class="stringliteral">&quot;TypeCode&quot;</span>, this.<a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a>);</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;        }</div>
<div class="line"><a name="l00167"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a681343928c67521c056568332690c424">  167</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a681343928c67521c056568332690c424" title="Skifter TypeCode for et User object fra LogInUser til CreateUser. ">SetAsCreateUser</a>()</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;        {</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a> == <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a>.LogInUser)</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;            {</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;                <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a> = <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a>.CreateUser;</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;            }</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;            <span class="keywordflow">else</span></div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;                <span class="keywordflow">throw</span> <span class="keyword">new</span> ArgumentException(<span class="stringliteral">&quot;Object is not a User!&quot;</span>);</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;        }</div>
<div class="line"><a name="l00180"></a><span class="lineno"><a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#add828aba2ab1d1a9016cc459ae3f1bc3">  180</a></span>&#160;        <span class="keyword">public</span> <span class="keywordtype">void</span> <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#add828aba2ab1d1a9016cc459ae3f1bc3" title="Finder en TypeCode ud fra objektets .GetType og gemmer det i TypeCode field. ">GetObjectType</a>(<span class="keywordtype">object</span> objectIn)</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;        {</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;            <span class="keywordflow">switch</span> (objectIn.GetType().ToString())</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;            {</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;                <span class="keywordflow">case</span> <span class="stringliteral">&quot;SW2A311_Lib.ProjectData&quot;</span>:</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;                    <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a> = <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a>.Project;</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;                    <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;                <span class="keywordflow">case</span> <span class="stringliteral">&quot;SW2A311_Lib.ChatMessageEncapsulation&quot;</span>:</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;                    <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a> = <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a>.Chat;</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;                    <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;                <span class="keywordflow">case</span> <span class="stringliteral">&quot;SW2A311_Lib.User&quot;</span>:</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;                    <a class="code" href="class_s_w2_a311___lib_1_1_encapsulation_class.html#a5bf4b3f50c67aa2a0450d2cfa6acc27b">TypeCode</a> = <a class="code" href="namespace_s_w2_a311___lib.html#abf922c6a2e5c0362bdf678f8102a3fa5">ObjectType</a>.LogInUser;</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;                    <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;                <span class="keywordflow">default</span>: <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;            }</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;        }</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;    }</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;<span class="preprocessor">    #endregion</span></div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;<span class="preprocessor"></span>}</div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_15ca01a5c548f04ea2501ecd174c056e.html">SW2A311_Lib</a></li><li class="navelem"><a class="el" href="_serialization_8cs.html">Serialization.cs</a></li>
    <li class="footer">Generated on Fri May 17 2013 11:47:21 for P2 Project - GanttMaker by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3.1 </li>
  </ul>
</div>
</body>
</html>
